<template>
  <div class="app-container" >
    <div class="boxfirst" style="font-size: 20px">
      <el-divider content-position="left" style="font-size: 100px" >系统历史离店客人清单</el-divider>
    </div>

    <template>

      <el-form :model="queryParams" ref="queryForm"  size="small" :inline="true" v-show="showSearch"  >

          <el-form-item label="手牌号" prop="handBrand" label-width="57px">
            <el-input
              v-model="queryParams.handBrand"
              placeholder="请输入手牌号"
              clearable
              style="width: 215px; "
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>

          <el-form-item label="团体号" prop="groupId" label-width="68px">
            <el-input
              v-model="queryParams.groupId"
              placeholder="请输入团体号"
              clearable
              style="width: 215px; "
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
      </el-form>
      <el-form>
          <el-form-item style="text-align: right;">
            <el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>
          </el-form-item>

      </el-form>



      <!--中间主体部分 -->

          <el-table v-loading="loading" :data="billsList" border  @selection-change="handleSelectionChange"
                    height="495"   style="width: 100%">
            <el-table-column type="index" label="序号"  :index="indexMethod" align="center"></el-table-column>
            <el-table-column prop="handBrand" align="center" sortable :sort-method="sortById" label="手牌号"></el-table-column>
            <el-table-column prop="openingTime" align="center" sortable label="入店时间" ></el-table-column>
            <el-table-column prop="groupId" align="center" sortable :sort-method="sortByTeam" label="团体号" ></el-table-column>
            <el-table-column prop="cardiner" align="center"  label="开牌人" ></el-table-column>
            <el-table-column prop="checkout"  align="center" label="结账人" ></el-table-column>
            <el-table-column prop="department" align="center" label="部门" ></el-table-column>
            <el-table-column prop="checkoutTime"  align="center" sortable label="离店时间" ></el-table-column>
            <el-table-column prop="frontSign" align="center" label="前台标志" ></el-table-column>
            <el-table-column prop="frontPrintTime"  align="center" sortable label="前台打印时间" ></el-table-column>
            <el-table-column prop="operator" align="center" label="操作员"></el-table-column>
            <el-table-column prop="checkoutLocation" align="center" label="结账位置" ></el-table-column>
           <!-- <el-table-column prop="note1" align="center" label="备注" width="215"></el-table-column> -->
          </el-table>

          <pagination
            v-show="total>0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
    </template>
  </div>
</template>

<script>

import { listBills, getBills, delBills, addBills, updateBills } from "@/api/module/zxy/xieba";
export default {
  name: "index111",
  dicts: ['yqg_hand_category', 'yqg_hand_state', 'yqg_retention_status', 'yqg_post', 'yqg_department', 'yqg_merge_status'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 吧台账单表格数据
      billsList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
        deptId: null,
        nickName: null,
        department: null,
        userName: null,
        post: null,
        handBrand: null,
        originalHand: null,
        handCategory: null,
        retentionStatus: null,
        mergeStatus: null,
        handState: '0',
        numberOfPeople: null,
        allCost: null,
        openingTime: null,
        groupId: null,
        oddNumbers: null,
        children: null,
        mastercard: null,
        handoverTime: null,
        handoverStatus: '0',
        barNumber: null,
        sailings: null,
        together: null,
        note: null,
        groupNotes: null,
        discountAmount: null,
        checkoutTime: null,
        supplementaryConsumption: null,
        paidInAmount: null,
        paidInCash: null,
        changeAmount: null,
        paymentMethod: null,
        totalConsumptionAmount: null,
        cardiner: null,
        checkout: null,
        frontSign: null,
        frontPrintTime: null,
        operator: null,
        checkoutLocation: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    sortById(a,b){
      if(parseInt(a.handBrand)>parseInt(b.handBrand)) {
        return -1
      }
    },
    sortByTeam(a,b){
      if(parseInt(a.groupId)>parseInt(b.groupId)) {
        return -1
      }
    },
    /** 查询吧台账单列表 */
    getList() {
      this.loading = true;
      listBills(this.queryParams).then(response => {
        this.billsList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        ID: null,
        userId: null,
        deptId: null,
        nickName: null,
        department: null,
        userName: null,
        post: null,
        handBrand: null,
        originalHand: null,
        handCategory: null,
        retentionStatus: null,
        mergeStatus: null,
        handState: null,
        numberOfPeople: null,
        allCost: null,
        openingTime: null,
        groupId: null,
        oddNumbers: null,
        children: null,
        mastercard: null,
        handoverTime: null,
        handoverStatus: null,
        barNumber: null,
        sailings: null,
        together: null,
        note: null,
        groupNotes: null,
        discountAmount: null,
        checkoutTime: null,
        supplementaryConsumption: null,
        paidInAmount: null,
        paidInCash: null,
        changeAmount: null,
        paymentMethod: null,
        totalConsumptionAmount: null,
        cardiner: null,
        checkout: null,
        frontSign: null,
        frontPrintTime: null,
        operator: null,
        checkoutLocation: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.ID)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加吧台账单";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const ID = row.ID || this.ids
      getBills(ID).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改吧台账单";
      });
    },
    indexMethod(index) {
      index = (index + 1) + (this.queryParams.pageNum - 1) * this.queryParams.pageSize
      return index
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.ID != null) {
            updateBills(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addBills(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete() {
      ppp(this.form).then(response => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('project/bills/export', {
        ...this.queryParams
      }, `bills_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
<style>

</style>
